﻿
$(document).ready(function () {

    $('#btnAddCustomer').click(function () {
        global.modalDialog.showModal("Test", "Modal test!");
    });

    $('#AmortHeader').bind('click', function () {
        var panelBody = $(this).next();
        //var panelPrevBody = $(this).prev();
        var icon = $(this).find('.dropPanelIcon2');

        if (panelBody.is(":hidden")) {
            // panelPrevBody.slideUp("fast");
            panelBody.slideDown("slow");
            icon.css("background-position", "-25px 0");
        } else {
            panelBody.slideUp(200);
            //panelPrevBody.slideDown("fast");
            icon.css("background-position", "0 0");
        }
    });



    /*REGION :  CALCULATION OF LOAN*/

    function CalculateLoan(loanAmount, loanCharge) {
        var _loanAmount = loanAmount.val();
        var calcResult = parseFloat(_loanAmount) - parseFloat(loanCharge.val());
        $('#txtPayable').val(calcResult);
        $('td.cellLoanAmount').html(_loanAmount);
    }

    /*Will access the global Function for checking if the inputted value is number*/
    var txtLoanAmount = $('#txtLoanAmount');
    var txtMonthlyPayment = $('#txtMonthlyPayment');

    txtLoanAmount.keypress(function (e) { return isNumberKey(e); });
    txtMonthlyPayment.keypress(function (e) { return isNumberKey(e); });

    txtLoanAmount.keyup(function (e) { CalculateLoan($('#txtLoanAmount'), $('#txtTotalCharges')); });
    txtMonthlyPayment.keyup(function (e) { CalculateLoan($('#txtLoanAmount'), $('#txtTotalCharges')); });

    /*END REGION :  CALCULATION OF LOAN*/

});